#include"MutationInverse.h"
#include"RandomGenerator.h"
#include"Evaluation.h"

using namespace std;

void MutationInverse::Mutate(Solution& solution)
{
	RandomGen<int> random(0 , Evaluation::GetJobNum() - 1);
	while(true)
	{
		int firstIndex = random();
		int secondIndex = random();
		if(firstIndex != secondIndex)
		{
			int halfLength = (secondIndex - firstIndex + 1) / 2;
			for(int offset = 0 ; offset < halfLength ; ++offset)
			{
				swap(solution[firstIndex + offset] , solution[secondIndex - offset]);
			}
			break;
		}
	}
}